<template>
    <div>
        <h1>登录页面</h1>
        <table class="table table-bordered">
            <tr>
                <td align="right" >账号</td>
                <td><input type="text" v-model="queryInfo.userName"  /></td>
            </tr>
            <tr>
                <td align="right" >密码</td>
                <td><input type="password" v-model="queryInfo.userPwd" /></td>
            </tr>
            <tr>
                <td></td>
                <td><input  type="button" value="登陆" class="btn btn-primary" @click="Login" /></td>
            </tr>
        </table>
    </div>
</template>

<script setup lang="ts">
import { reactive,ref } from 'vue';
//用来实现页面跳转
import {useRoute, useRouter} from 'vue-router'
///引入axios
import axios from 'axios';
//创建一个路由器  跳转传参
const router=useRouter();

let queryInfo=reactive({
    userName:'',
    userPwd:'',
})
const Login=()=>{
    if(queryInfo.userName==""){
        alert("账户不能为空!");
        return;
    }
    if(queryInfo.userPwd==""){
        alert("密码不能为空!");
        return;
    }
   axios({
    url:'https://localhost:7035/api/ZAdmins/GetAdminInfo',//请求地址
    method:'get',//
    params:queryInfo
})
.then((res)=>{
    console.log(res.data);
    if(res.data!=''){
        router.push("/memberList");
    }
    else{
        alert("没有用户!");
    }
    
})
.catch((err)=>{
 console.log(err);   
})
}
</script>

<style scoped>

</style>